package cn.deepxi.org.service.impl;

import cn.deepxi.org.domain.Employee;
import cn.deepxi.org.mapper.EmployeeMapper;
import cn.deepxi.org.query.EmployeeQuery;
import cn.deepxi.org.service.IEmployeeService;
import cn.deepxi.utils.QueryResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class EmployeeImpl implements IEmployeeService {
    @Autowired
    private EmployeeMapper employeeMapper;
    @Override
    @Transactional
    public List<Employee> loadAll() {
        return employeeMapper.loadAll();
    }

    @Override
    @Transactional
    public void save(Employee d) {
        employeeMapper.save(d);
    }

    @Override
    @Transactional
    public void remove(Long id) {
        employeeMapper.remove(id);
    }

    @Override
    @Transactional
    public void update(Employee d) {
        employeeMapper.update(d);
    }

    @Override
    @Transactional
    public Employee loadById(Long id) {

        return employeeMapper.loadById(id);
    }

    @Override
    @Transactional
    public QueryResult<Employee> queryPage(EmployeeQuery query) {
        Long count = employeeMapper.queryCount(query);
        List<Employee> employees = employeeMapper.queryData(query);
        return new QueryResult<Employee>(count,employees);
    }

    @Override
    @Transactional
    public void batchRemove(Long[] ids) {
        employeeMapper.batchRemove(ids);
    }


}
